package com.aurora.app.controller;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;
import com.aurora.app.entity.User;
import com.aurora.app.enums.FakeDelete;
import com.aurora.app.service.UserService;

/**
 * 共有的服务
 * @author yongjiang.lin
 *
 */
@Controller
@RequestMapping(value = "api/common")
public class CommonController {
	@Resource
	private UserService userService;
	
	
	@RequestMapping(value = "/getUser")
	@ResponseBody
	public String getUser(HttpServletRequest request,String uid){
		User user = this.userService.get(uid);
		Map<String,Object> map = new  HashMap<String,Object>();
		if(user == null || user.getIsDelete().equals(FakeDelete.NODELETE)){
			map.put("STATUS", "ERR");
			map.put("DESC", "无法找到用户信息");
			return JSON.toJSONString(map);
		}
		map.put("ID", user.getId());
		map.put("NAME", user.getNickName());
		map.put("IMGURL", user.getHeadimgurl());
		map.put("STATUS", "OK");
		return JSON.toJSONString(map);
	}
}
